import { _decorator, Component, Node } from 'cc';
import { PlayerState } from './PlayerState';
const { ccclass, property } = _decorator;

@ccclass('PlayerStateMachine')
export class PlayerStateMachine {
    public  currentState: PlayerState | null = null;

    public Initialize(_startState: PlayerState) {
        this.currentState = _startState;
        this.currentState.enter();
    }

    // 切换状态
    public changeState(newState: PlayerState): void {
        if (this.currentState) {
            this.currentState.exit(); // 退出当前状态
        }
        this.currentState = newState;
        this.currentState.enter();    // 进入新状态
    }


}


